
/**
 * Title: CheckUtils.java
 * Package: com.travelsky.pss.ri.util
 * Copyright: Copyright(c) 2015 Travelsky All Rights Reserved
 * Company: Travelsky
 * Product Line: Revenue Integrity
 * Description: 检查工具类
 * Date: 2015-12-24 下午1:06:12
 * @author hpeng@travelsky.com
 * @version 1.0
 */

package com.share.util;

import java.util.List;
import java.util.Map;
import java.util.Set;


/**
 * <p>Title: CheckUtils </p>
 * <p>Description: 检查工具类 </p>
 * Date: 2015-12-24 下午1:06:12
 * @author hpeng@travelsky.com
 * @version 1.0 </p> 
 * Significant Modify：
 * Date               Author           Content
 * ==========================================================
 * 2015-12-24         hpeng         创建文件,实现基本功能
 * 
 * ==========================================================
 */
public final class RiCheckUtils {
	
	/**
	 * <p>Title: RiCheckUtils </p>
	 * <p>Description: Constructor </p>  
	 */
	private RiCheckUtils() {
	}

	/**
	 * <p>Title: isEmpty </p>
	 * <p>Description: 字符串判断为空 </p>
	 * <pre>
     * CheckUtils.isEmpty(null)      = true
     * CheckUtils.isEmpty("")        = true
     * CheckUtils.isEmpty(" ")       = true
     * CheckUtils.isEmpty("bob")     = false
     * CheckUtils.isEmpty("  bob  ") = false
     * </pre>
	 * @param str 需要判断的字符串
	 * @return booean
	 */
	public static boolean isEmpty(String str) {
		if (null == str) {
			return true;
		}
		return str.trim().length() == 0;
    }
	
	/**
	 * <p>Title: isNotEmpty </p>
	 * <p>Description: 字符串判断不为空  </p>
	 * <pre>
     * CheckUtils.isNotEmpty(null)      = false
     * CheckUtils.isNotEmpty("")        = false
     * CheckUtils.isNotEmpty(" ")       = false
     * CheckUtils.isNotEmpty("bob")     = true
     * CheckUtils.isNotEmpty("  bob  ") = true
     * </pre>
	 * @param str 需要判断的字符串
	 * @return booean
	 */
	public static boolean isNotEmpty(String str) {
        return !isEmpty(str);
    }
	
	/**
	 * <p>Title: isEmpty </p>
	 * <p>Description: 判断List为空 </p>
	 * <pre>
	 * null == list || list.isEmpty()
	 * </pre>
	 * @param list 需要判断的List
	 * @return boolean
	 */
	public static boolean isEmpty(List<?> list) {
		return null == list || list.isEmpty();
	}
	
	/**
	 * <p>Title: isNotEmpty </p>
	 * <p>Description: 判断List不为空 </p>
	 * <pre>
	 * null != list && !list.isEmpty()
	 * </pre>
	 * @param list 需要判断的List
	 * @return boolean
	 */
	public static boolean isNotEmpty(List<?> list) {
		return null != list && !list.isEmpty();
	}
	
	/**
	 * <p>Title: isEmpty </p>
	 * <p>Description: 判断Set为空 </p>
	 * <pre>
	 * null == set || set.isEmpty()
	 * </pre>
	 * @param set 需要判断的set
	 * @return boolean
	 */
	public static boolean isEmpty(Set<?> set) {
		return null == set || set.isEmpty();
	}
	
	/**
	 * <p>Title: isNotEmpty </p>
	 * <p>Description: 判断Set不为空 </p>
	 * <pre>
	 * null != set && !set.isEmpty()
	 * </pre>
	 * @param set 需要判断的set
	 * @return boolean
	 */
	public static boolean isNotEmpty(Set<?> set) {
		return null != set && !set.isEmpty();
	}
	
	/**
	 * <p>Title: isEmpty </p>
	 * <p>Description: 判断Map为空 </p>
	 * <pre>
	 * null == map || map.isEmpty()
	 * </pre>
	 * @param map 需要判断的map
	 * @return boolean
	 */
	public static boolean isEmpty(Map<?, ?> map) {
		return null == map || map.isEmpty();
	}
	
	/**
	 * <p>Title: isNotEmpty </p>
	 * <p>Description: 判断Map不为空 </p>
	 * <pre>
	 * null != map && !map.isEmpty()
	 * </pre>
	 * @param map 需要判断的map
	 * @return boolean
	 */
	public static boolean isNotEmpty(Map<?, ?> map) {
		return null != map && !map.isEmpty();
	}
	
	/**
	 * <p>Title: isEmpty </p>
	 * <p>Description: 判断数组为空 </p>
	 * <pre>
	 * null == objArray || objArray.length == 0
	 * </pre>
	 * @param objArray 需要判断的数组
	 * @return boolean
	 */
	public static boolean isEmpty(Object[] objArray) {
		return null == objArray || objArray.length == 0;
	}
	
	/**
	 * <p>Title: isEmpty </p>
	 * <p>Description: 判断数组不为空 </p>
	 * <pre>
	 * null != objArray && objArray.length > 0
	 * </pre>
	 * @param objArray 需要判断的数组
	 * @return boolean
	 */
	public static boolean isNotEmpty(Object[] objArray) {
		return null != objArray && objArray.length > 0;
	}
}
